package com.prtek.reminder.helper;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.net.Uri;
import com.prtek.reminder.bean.DaoMaster;
import com.prtek.reminder.bean.NotesDao;
import com.prtek.reminder.bean.NotesJoinUserDao;
import com.prtek.reminder.bean.RemindUserDao;

/**
 * Created by jarly on 2018/8/31.
 */

public class UpgradeHelper extends DaoMaster.OpenHelper {
  public static final String AUTHORITY = "com.prtek.iis.remind";
  public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY);
  public static final String NAME = "remind.db";
  private static UpgradeHelper helper;

  public UpgradeHelper(Context context) {
    super(context, NAME, null);
  }

  @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    MigrationHelper.migrate(db, NotesDao.class, NotesJoinUserDao.class, RemindUserDao.class);
  }

  public static UpgradeHelper getInstance(Context context) {
    if (helper == null) {
      synchronized (UpgradeHelper.class) {
        if (helper == null) {
          helper = new UpgradeHelper(context);
        }
      }
    }
    return helper;
  }
}
